import request from '@/utils/request'

export function Get(id, args) {
  return request({
    url: `/cms/api/post/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function Post(data) {
  return request({
    url: '/cms/api/post/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function Put(id, data) {
  return request({
    url: `/cms/api/post/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: data
  })
}

export function Delete(id) {
  return request({
    url: `/cms/api/post/${id || ''}`,
    method: 'delete'
  })
}

export function GetHistory(id, args) {
  return request({
    url: `/cms/api/post_history/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function dt(data) {
  return request({
    url: '/cms/api/post/dt/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function InsertInnerLink(data) {
  return request({
    url: '/cms/api/post/insert_inner_link/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function duplicate_check(data) {
  return request({
    url: '/cms/api/post/duplicate_check/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function InsertInnerImage(data) {
  return request({
    url: '/cms/api/post/insert_inner_image/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function AddPostShare(id, args) {
  return request({
    url: `/cms/api/add_post_share/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function dashboard_posts(data) {
  return request({
    url: '/cms/api/dashboard_posts/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

// 翻译任务相关接口
export function GetTranslateTaskList(args) {
  return request({
    url: `/cms/api/post_translate_task/${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function GetTranslateTask(id) {
  return request({
    url: `/cms/api/post_translate_task/${id}/`,
    method: 'get'
  })
}

export function CreateTranslateTask(data) {
  return request({
    url: '/cms/api/post_translate_task/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function UpdateTranslateTask(id, data) {
  return request({
    url: `/cms/api/post_translate_task/${id}/`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: data
  })
}

export function DeleteTranslateTask(id) {
  return request({
    url: `/cms/api/post_translate_task/${id}/`,
    method: 'delete'
  })
}

// 重新翻译接口
export function PostRetranslate(data) {
  return request({
    url: '/cms/api/post_retranslate/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

// 获取翻译状态接口
export function GetTranslationStatus(postId) {
  return request({
    url: `/cms/api/post_translation_status/?post_id=${postId}`,
    method: 'get'
  })
}

// 获取最近30天发帖列表
export function recent_posts() {
  return request({
    url: '/cms/api/recent_posts/',
    method: 'get'
  })
}
